package com.funsport.controller.mobile;

import com.funsport.common.Result;
import com.funsport.service.IStatisticsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 移动端排行榜Controller
 *
 * @author Fun-Sport Team
 */
@Slf4j
@Tag(name = "移动端排行榜", description = "移动端排行榜相关接口")
@RestController
@RequestMapping("/mobile/ranking")
@RequiredArgsConstructor
public class MobileRankingController {

    private final IStatisticsService statisticsService;

    @Operation(summary = "获取俱乐部排行榜")
    @GetMapping("/clubs")
    public Result<Map<String, Object>> getClubRankings(
            @RequestParam(defaultValue = "activity") String type,
            @RequestParam(defaultValue = "10") Integer limit) {
        Map<String, Object> rankings = statisticsService.getClubRankings(type, limit);
        return Result.success(rankings);
    }

    @Operation(summary = "获取用户排行榜")
    @GetMapping("/users")
    public Result<Map<String, Object>> getUserRankings(
            @RequestParam(defaultValue = "points") String type,
            @RequestParam(defaultValue = "10") Integer limit) {
        Map<String, Object> rankings = statisticsService.getUserRankings(type, limit);
        return Result.success(rankings);
    }

    @Operation(summary = "获取运动类型热度")
    @GetMapping("/sport-popularity")
    public Result<Map<String, Object>> getSportTypePopularity(
            @RequestParam(defaultValue = "30") Integer days) {
        Map<String, Object> stats = statisticsService.getSportTypePopularity(days);
        return Result.success(stats);
    }
}

